//
//  Buttons.swift
//  Demo3
//
//  Created by Bigboss on 2025/3/7.
//

import SwiftUI

// MARK: - 组件
struct RotationButton: View {
    enum Axis {
        case x, y, z
        
        var icon: String {
            switch self {
            case .x: return "arrow.right"
            case .y: return "arrow.up"
            case .z: return "arrow.clockwise"
            }
        }
        
        var label: String {
            switch self {
            case .x: return "X轴"
            case .y: return "Y轴"
            case .z: return "Z轴"
            }
        }
    }
    
    let axis: Axis
    let action: () -> Void
    
    var body: some View {
        Button(action: action) {
            VStack {
                Image(systemName: axis.icon)
                    .font(.title3)
                    .rotationEffect(.degrees(axis == .z ? -90 : 0))
                Text(axis.label)
                    .font(.system(size: 12))
            }
            .frame(width: 80, height: 60)
            .background(.thinMaterial)
            .cornerRadius(12)
        }
        .buttonStyle(.plain)
    }
}


struct ToggleButton: View {
    let action: () -> Void
    
    var body: some View {
        Button(action: action) {
            Image(systemName: "arrow.left")
                .font(.system(size: 24))
                .frame(width: 44, height: 44)
                .background(.thinMaterial)
                .clipShape(Circle())
        }
        .buttonStyle(.plain)
    }
}
